package com.video.controller;

import com.video.bean.Video;
import com.video.service.VideoServiceI;
import com.video.service.VipServiceI;
import com.video.utils.ResultMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
public class VideoController {
    @Autowired
    private VideoServiceI videoServiceI;

    @RequestMapping("/selectAllVideo")
    @ResponseBody
    public ResultMap selectAllVideo() { return videoServiceI.selectAllVideo(); }

    @RequestMapping("/selectAllVideoByLimit")
    @ResponseBody
    public ResultMap selectAllVideoByLimit(int page,int limit) { return videoServiceI.selectAllVideoByLimit(page,limit); }

    @RequestMapping("/selectVideoByTid")
    @ResponseBody
    public ResultMap selectVideoByTid(String tid) { return videoServiceI.selectVideoByTid(tid); }

    @RequestMapping("/selectVideoByVid")
    @ResponseBody
    public ResultMap selectVideoByVid(String vid,HttpSession sesion) { return videoServiceI.selectVideoByVid(vid,sesion); }

    @RequestMapping("/createVideo")
    public String uploadVideo(Video video, HttpServletRequest request) {
        videoServiceI.createVideo(video, request);
        return "pages/manager/videoManager";
    }

    @RequestMapping("/updateVideoByVId")
    @ResponseBody
    public ResultMap updateVideoByVId(String videoStr) {
        return videoServiceI.updateVideoByVId(videoStr);
    }

    @RequestMapping("/deleteVideoByVid")
    @ResponseBody
    public ResultMap deleteVideoByVid(String vid) {
        return videoServiceI.deleteVideoByVid(vid);
    }

}
